<%--
  Created by IntelliJ IDEA.
  User: xiaoji
  Date: 2014/11/24
  Time: 14:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="session"/>
<!DOCTYPE html>

<html>
<head>
    <title>用户管理</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="${path}/plugins/jquery-easyui-1.4.1/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${path}/plugins/jquery-easyui-1.4.1/themes/icon.css">
    <script type="text/javascript" src="${path}/plugins/jquery-easyui-1.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="${path}/plugins/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${path}/plugins/jquery-easyui-1.4.1/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#search").click(function(){
                $('#tt').datagrid('load',{
                    userName:$("#userName").val()
                });
            });
        });
    </script>
</head>
<body class="easyui-layout">
<div region="center" style="padding:5px;" border="false">
    <!--列表-->
    <table id="tt" class="easyui-datagrid" title="用户基本信息管理"
           data-options="singleSelect:true,collapsible:true,url:'${path}/user/view.do',
       method:'get',toolbar:'#tb',footer:'#ft',pagination:'true',fit:'true'">
        <thead>
        <tr>
            <th data-options="field:'userName',align:'center',width:80">用户名</th>
            <th data-options="field:'nickname',align:'center',width:80">昵称</th>
            <th data-options="field:'phone',align:'center',width:80">电话</th>
            <th data-options="field:'email',align:'center',width:80">邮箱</th>
            <th data-options="field:'country',align:'center',width:80">国家</th>
            <th data-options="field:'addr',align:'center',width:80">地址</th>
            <th data-options="field:'headPortrait',align:'center',width:80,formatter:function(v){return '<img width=\'30px\' height=\'30px\' src=/'+v+'>'}">头像</th>
            <th data-options="field:'skillName',align:'center',width:80">技能</th>
            <th data-options="field:'alipay',align:'center',width:80">支付宝</th>
            <th data-options="field:'createTime',align:'center',width:80,formatter:function(v){if(v == null || v == 101001) return '是'; else return '否';}">是否有效</th>
            <th data-options="field:'ispoReceiver',align:'center',width:80,formatter:function(v){if(v == 101001) return '是'; if(v == 101002) return '否';}">接包首次推广</th>
            <th data-options="field:'ispoSender',align:'center',width:80,formatter:function(v){if(v == 101001) return '是'; if(v == 101002) return '否';}">发包首次推广</th>
            <th data-options="field:'presenter',align:'center',width:80">推荐者</th>
            <th data-options="field:'latestTime',align:'center',width:80">最近登录时间</th>
            <th data-options="field:'feeNum',align:'center',width:80">零手续费卡片数量</th>
            <th data-options="field:'wallet',align:'center',width:80">我的钱包</th>
            <th data-options="field:'freezeMoney',align:'center',width:80">冻结金额</th>
            <th data-options="field:'totalFavorite',align:'center',width:80">被关注统计</th>
            <th data-options="field:'totalFavorite2',align:'center',width:80">关注用户+totalFavorite3</th>
            <th data-options="field:'isTotal',align:'center',width:80,formatter:function(v){if(v == null || v == 101001) return '是'; else return '否';}">是否统计</th>
            <th data-options="field:'pointNum',align:'center',width:80">点数</th>
            <th data-options="field:'integral',align:'center',width:80">积分</th>
            <th data-options="field:'blacklist',align:'center',width:80">黑名单</th>
            <th data-options="field:'artistLevel',align:'center',width:80">艺术家等级</th>
            <th data-options="field:'nameAuth',align:'center',width:80,formatter:function(v){if(v == 101001) return '已认证'; else return '未认证';}">身份认证</th>
            <th data-options="field:'intro_simplify',align:'center',width:80">艺术家自我介绍</th>
            <th data-options="field:'intro',align:'center',width:80">发包方自我介绍</th>
        </tr>
        </thead>
    </table>
</div>
<!--头工具项-->
<div id="tb" style="padding:2px 5px;">
    用户名: <input class="easyui-textbox" name="userName" id="userName" style="width:110px">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="search">查找</a>
</div>
<!--尾工具项-->
<div id="ft" style="padding:2px 5px;">
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="openDlg1()">改变艺术家等级</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="openDlg2()">身份认证</a>
</div>
<!--提升艺术家等级-->
<div id="dlg1" class="easyui-dialog" style="width:400px;height:380px;padding:10px 20px"
     closed="true" buttons="#dlg-buttons1" title="艺术家等级">
    <div class="ftitle">艺术家等级</div>
    <form id="fm1" method="post" class="fm">
        <div class="fitem">
            <label>艺术家等级:</label>
            <select class="easyui-combobox" panelHeight="auto" name="artistL" id="artistL" style="width:100px">
                <c:forEach items="${levels}" var="l">
                    <option value="${l.minor_id}">${l.level}</option>
                </c:forEach>
            </select>
        </div>
    </form>
</div>
<div id="dlg-buttons1">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="changeArtistLevel()" style="width:90px">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg1').dialog('close')" style="width:90px">取消</a>
</div>
<!--身份认证-->
<div id="dlg2" class="easyui-dialog" style="width:450px;height:380px;padding:10px 20px"
     closed="true" buttons="#dlg-buttons2" title="身份认证">
    <div class="ftitle">身份认证</div>
    <form id="fm2" method="post" class="fm">
        <div class="fitem">
            <label>真实姓名:</label>
            <span id="realName"></span>
        </div>
        <div class="fitem">
            <label>身份证:</label>
            <span id="isCard"></span>
        </div>
    </form>
</div>
<div id="dlg-buttons2">
    <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="cardAuth()" style="width:90px">认证</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg2').dialog('close')" style="width:90px">取消</a>
</div>
<script>
    function openDlg1(){
        var row = $('#tt').datagrid('getSelected');
        if (row){
            $('#dlg1').dialog('open');
        }
    }
    function changeArtistLevel(){
        var row = $('#tt').datagrid('getSelected');
        if (row) {
            $.post("${path}/user/changeArtistLevel.do",{
                userId:row.userId,
                level:$('#artistL').combobox('getValue')
            },function(data){
                if(data.errormsg == undefined){
                    $.messager.alert("提示","保存成功","info");
                    $('#tt').datagrid('updateRow', {
                        index:$('#tt').datagrid('getRowIndex', row),
                        row : {
                            artistLevel:$('#artistL').combobox('getText')
                        }
                    });
                    $('#dlg1').dialog('close');
                }else{
                    $.messager.alert("错误提示",data.errormsg,"error");
                }
            },"json");
        }
    }

    function openDlg2(){
        var row = $('#tt').datagrid('getSelected');
        if (row){
            $("#realName").html(row.realName);
            if(row.idCard != null){
                var img= "";
                var arr = row.idCard.split(",");
                for(var i =0; i<arr.length;i++){
                    img+='<img src="/'+arr[i]+'" width="350px" heigth="350px"/>';
                }
            }
            $("#isCard").html(img);
            $('#dlg2').dialog('open');
        }
    }
    <!--认证-->
    function cardAuth(){
        var row = $('#tt').datagrid('getSelected');
        if (row) {
            $.post("${path}/user/changeNameAuth.do",{
                userId:row.userId
            },function(data){
                if(data.errormsg == undefined){
                    $.messager.alert("提示","认证成功","info");
                    $('#tt').datagrid('updateRow', {
                        index:$('#tt').datagrid('getRowIndex', row),
                        row : {
                            nameAuth:101001
                        }
                    });
                    $('#dlg2').dialog('close');
                }else{
                    $.messager.alert("错误提示",data.errormsg,"error");
                }
            },"json");
        }
    }
</script>
<style type="text/css">
    .fm{
        margin:0;
        padding:10px 30px;
    }
    .ftitle{
        font-size:14px;
        font-weight:bold;
        padding:5px 0;
        margin-bottom:10px;
        border-bottom:1px solid #ccc;
    }
    .fitem{
        margin-bottom:5px;
    }
    .fitem label{
        display:inline-block;
        width:80px;
    }
    .fitem input{
         width:160px;
     }
</style>
</body>
</html>
